package com.dubbo.cp.consumer.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dubbo.cp.IService.DemoService;
import com.dubbo.cp.IService.UserService;
import com.dubbo.cp.entity.UserEntity;



@RestController
public class DemoConsumerController {
    @Reference
    /*(version = "${demo.service.version}",
            application = "${dubbo.application.id}",
            url = "dubbo://localhost:20880")
            */
    private DemoService demoServiceImpl;

    @Reference
    private UserService userServiceImpl;
    
    @RequestMapping("/sayHello")
    public String sayHello() {
        return demoServiceImpl.sayHello();
    }
    /*@RequestMapping("/getUser")
    public String getUser() {
    	//System.out.println("/getUser"+userServiceImpl.getUser());
        return userServiceImpl.getUser();
    }*/
    @RequestMapping(value = "/findUserByUserid/{id}", method = RequestMethod.GET)
    public UserEntity findUserByUserid(@PathVariable int id) {
		return userServiceImpl.findUserByUserid(id);
    	
    }
    @RequestMapping(value = "/insert", method = RequestMethod.GET)
    public void insert(@RequestParam("username") String username,@RequestParam("password") String password) {
    	System.out.println(username+password);
    	userServiceImpl.insertUserEntity(username, password);
    	
		
    	
    }
}
